// 主界面
;
define(function(require, exports, module) {
	'use strict';
	var util = require("util");
	var base = require("base");
	var dialog = require("dialog");
	var validate = require("validate");
	var randomCode;
	var inventoryId;
	var tools;
	var ninventoryId;
	var databind = require("databind");
	
	var init = function() {
		randomCode = base.getUrlParam("randomCode");
		initEvent();
	};
	var initEvent = function() {
		
		setInterval(function() {
			getPassedData(randomCode, function(){
				if (ninventoryId != inventoryId) {
					inventoryId = ninventoryId;
					showFile(ninventoryId);
				} else {
					
				}
			});
		}, 1000);
	};
	
	
	//查询货箱信息
	var showFile = function(inventoryId){
		var src = "/finance/api/v1.0/downloadFile.file?fileUuid=" + inventoryId;
		$("embed").attr("src", src);
		$("title").html(tools.inquireFile(inventoryId));
	};
	
	var getPassedData = function(randomCode, callback) {
		base.fnAjax({
			action: "getPassedData.json",
			oData: {
				randomCode: randomCode
			},
			fnSuccess: function(data) {
				if (data.status == 200) {
					ninventoryId = data.datas[0].data;
					callback();
				} else {
					base.alert(3, data.message);
				}
			}
		});
	}
	
	return {
		init: init
	};
});